import {defineStore} from "pinia";
import {getAppConfig} from "@/api";
import {ref} from 'vue'

export const useAppConfigStore = defineStore('appconfig', ()=>{
    const appconfig = ref(),
        key = 'appconfig';
    const getConfig = ()=>{
        if(uni.getStorageSync(key)){
            appconfig.value = JSON.parse(uni.getStorageSync(key));
        }else {
            getAppConfig().then(r=>{
                appconfig.value = r
                uni.setStorageSync(key,JSON.stringify(r))
            })
        }
    }


    return { appconfig ,getConfig}
})